package edu.bit.water.dao;

import edu.bit.water.dto.WaterCondition;
import edu.bit.water.dto.WaterWarningCondition;
import edu.bit.water.dto.WarningRule;
import edu.bit.water.entity.WarningRecord;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Mapper
@Repository
public interface WarningRecordDao {
    List<Map<String, Object>> queryWarningRecord(@Param("sensorRowId") String sensorRowId, @Param("waterWarningCondition") WaterWarningCondition waterWarningCondition);
    //根据传感器编号和查询日期条件查询数据
    List<HashMap<String, Object>> queryRecordByCondition(@Param("sensorRowId") String sensorRowId, @Param("waterWarningCondition") WaterWarningCondition waterWarningCondition);
    List<String> querySensorNames(@Param("sensorRowId") String sensorRowId, @Param("companyId") Integer companyId);
    List<Map<String, Object>> selectByDate(@Param("waterWarningCondition")WaterWarningCondition waterWarningCondition);
    //查询所有车间
    List<String> queryWorkshop();
    //根据公司id查询该公司所有车间
    List<String> queryWorkshopByCompanyId(@Param("companyId") int company_id);
    //根据车间查传感器类型
    List<String> querySortByWorkshop(@Param("workShopSql") String workShopSql, @Param("techProcessId") String techProcessId);
    //根据车间和传感器查设备编号
    List<String> querySensorRowIdByWorshopAndsort(@Param("techProcessId") String techProcessId, @Param("workShopSql") String workShopSql,@Param("sortSql")String sortSql);
    List<String> querySensorRowIdByWorkshopAndsort(@Param("businessId") String businessId, @Param("workShopSql") String workShopSql,@Param("sortSql")String sortSql);
    List<WarningRule> queryWarningRuleBySensorId(@Param("sensorId") String sensorId);
    List<WarningRule> queryWarningRuleBySensorIdAndCompanyId(@Param("sensorId") String sensorId, @Param("companyId") int companyId);
    List<String> selectAllSensors();
	
	
    List<WarningRule> getAllRules();
    int getSumOfEntityWater(@Param("beginTime") String beginTime, @Param("endTime") String endTime);
    int getSumOfWarningRecord(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("warningRule") WarningRule warningRule);

    Date queryLastTime();
    int addWarningRecord(WarningRecord record);
    List<WarningRecord> queryWarningRecordByWarningConditionAndCompanyId(WaterWarningCondition condition);
}
